
import Head from 'next/head'

<Head>
  <script>
    {
      `(function() {
         var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?e60fb290e204e04c5cb6f79b0ac1e697";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
       })();`
    }
  </script>
</Head>

![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif)





OpenAI[#](#openai "此标题的永久链接")
===============================================

让我们加载OpenAI嵌入类。

```python
from langchain.embeddings import OpenAIEmbeddings

```

```python
embeddings = OpenAIEmbeddings()

```

```python
text = "This is a test document."

```

```python
query_result = embeddings.embed_query(text)

```

```python
doc_result = embeddings.embed_documents([text])

```

让我们加载带有第一代模型（例如“text-search-ada-doc-001 / text-search-ada-query-001”)的OpenAI嵌入类。注意：这些不是推荐的模型-请参见[此处](https://platform.openai.com/docs/guides/embeddings/what-are-embeddings)。

```python
from langchain.embeddings.openai import OpenAIEmbeddings

```

```python
embeddings = OpenAIEmbeddings()

```

```python
text = "This is a test document."

```

```python
query_result = embeddings.embed_query(text)

```

```python
doc_result = embeddings.embed_documents([text])

```

